#!/bin/bash

file="../Driver/date_time_now.c"


year=`date +%Y | sed -r 's/0*([0-9])/\1/'`
Date=`date +%d | sed -r 's/0*([0-9])/\1/'`
Month=`date +%m | sed -r 's/0*([0-9])/\1/'`
WeekDay=`date +%w | sed -r 's/0*([0-9])/\1/'`
Hours=`date +%H | sed -r 's/0*([0-9])/\1/'`
Minutes=`date +%M | sed -r 's/0*([0-9])/\1/'`
Seconds=`date +%S | sed -r 's/0*([0-9])/\1/'`



echo "
#include \"date_time.h\"

RTC_DateTypeDef now_date = 
{
  .WeekDay = ${WeekDay},
  .Month = ${Month},
  .Date = ${Date},
  .Year = ${year}-2000
};

RTC_TimeTypeDef now_time = 
{
  .Hours = ${Hours}, /*0~23*/

  .Minutes = ${Minutes}, /*0~59 */

  .Seconds = ${Seconds}, /*0 ~59 */
};

" > ${file}
